<me:UIPRG x:Class="WPFExcelReport.TPRG"
                    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                    xmlns:ucd="clr-namespace:ReflectionStudio.Controls;assembly=ReflectionStudio.Controls"     
                    xmlns:me="clr-namespace:WPFExcelReport" 
                    xmlns:FN="clr-namespace:WPFExcelReport;assembly=TICC_FUNCTIONS"  
                    xmlns:SD="clr-namespace:WPFExcelReport;assembly=TSDDAT"  
                    xmlns:Localization="clr-namespace:Localization;assembly=Localization"
                    xmlns:ex="clr-namespace:WPFExcelReport.Controls;assembly=ExControls" 
                    x:Name="TV"
                    FontSize="14"
                    Loaded="Window_Loaded"
     >
    <me:UIPRG.Resources>
        <CollectionViewSource  x:Key="vwMaster"/>       <CollectionViewSource  x:Key="vwDetail"/>
        <ucd:BoolToVisibilityConverter  x:Key="bv"/>
        <ucd:GB2312Convert8859P1  x:Key="gb2312"/>
        <ucd:NOTConverter  x:Key="not"/>
    </me:UIPRG.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="1*"></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="1*"></ColumnDefinition>
            <ColumnDefinition Width="1*"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <StackPanel>
            <WrapPanel> 
                <WrapPanel>
                    <Grid Margin="10,0,0,0" >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <Button   Click="NewCommand" Height="20" Margin="5,0,0,0" Width="24" >
                            <Button.Background>
                                <ImageBrush  ImageSource="/ImagePackage;component/Images/Add.png" />
                            </Button.Background>
                        </Button>
                    </Grid>
                    <WrapPanel Visibility="{Binding IsNew,ElementName=TV,Converter={StaticResource bv}}">
                        <SD:K8887  Grid.Column="1" 
                               Name="cFC"
                               IsEdit="True" 
                               KEY="{Binding CONTROLS,ElementName=TV}"/>
                        <TextBlock Text="{Binding Source={Localization:Translate Word=目标属性}}"></TextBlock>
                        <Button   Click="NewCommand" Height="20" Margin="5,0,0,0" Width="24" >
                            <Button.Background>
                                <ImageBrush  ImageSource="/ImagePackage;component/Images/button_ok.png" />
                            </Button.Background>
                        </Button>
                    </WrapPanel>
                </WrapPanel>
                <Grid Margin="10,0,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Button  Click="EditCommand" Width="24" Height="20">
                        <Button.Background>
                            <ImageBrush  ImageSource="/ImagePackage;component/Images/Edit.png" />
                        </Button.Background>
                    </Button>
                </Grid>
                <Grid Margin="10,0,0,0" >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Button Click="DeleteCommand" Height="20" Margin="5,0,0,0" Width="24" >
                        <Button.Background>
                            <ImageBrush  ImageSource="/ImagePackage;component/Images/Remove.png" />
                        </Button.Background>
                    </Button>
                </Grid>
                <Grid Margin="10,0,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Button    Click="CopyCommand" Height="20" Margin="5,0,0,0" Width="24" >
                        <Button.Background>
                            <ImageBrush  ImageSource="/ImagePackage;component/Images/copy.png" />
                        </Button.Background>
                    </Button>
                </Grid>
                <Grid Margin="10,0,0,0" Visibility="{Binding IsEdit,ElementName=TV,Converter={StaticResource bv}}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Button   Click="SaveCommand" Height="20" Margin="5,0,0,0" Width="24" >
                        <Button.Background>
                            <ImageBrush  ImageSource="/ImagePackage;component/Images/Save.png" />
                        </Button.Background>
                    </Button>
                </Grid>
               
            </WrapPanel>
            <WrapPanel>
                <Grid Margin="10,0,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <TextBlock  Grid.Column="0" Text="{Binding Source={Localization:Translate Word=控制项:}}"></TextBlock>
                    <SD:K8887  Grid.Column="1"  
                               IsEdit="{Binding IsEdit,ElementName=TV}"
                               ORDERNUM="{Binding CONTROLS,ElementName=TV}"
                               DES="{Binding REMARK,ElementName=TV}"
                               KEY="{Binding CONTROLS,ElementName=TV}"/>
                </Grid>
                <WrapPanel >                    
                    <Grid Margin="10,0,0,0" Visibility="Collapsed">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <TextBlock  Grid.Column="0" Text="{Binding Source={Localization:Translate Word=子控件:}}"></TextBlock>
                        <ex:TXT72 MaxLength="40" Grid.Column="1"  Text="{Binding P1}" Width="100" />
                    </Grid>
                </WrapPanel>
                <Grid Margin="10,0,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <TextBlock  Grid.Column="0" Text="{Binding Source={Localization:Translate Word=说明:}}"></TextBlock>
                    <ex:TXT72 MaxLength="40" Grid.Column="1" 
                              Text="{Binding REMARK,Converter={StaticResource gb2312}}" Width="200" />
                </Grid>

            </WrapPanel>
        </StackPanel>
        <DataGrid  Grid.Row="1"  
                   VerticalAlignment="Top" 
                   AutoGenerateColumns="False"
                   EnableRowVirtualization="False"
                   VerticalScrollBarVisibility="Auto"
                   HorizontalScrollBarVisibility="Auto"
                   HeadersVisibility="Column"  
                   ItemsSource="{Binding Source={StaticResource vwMaster}}"  
                   IsSynchronizedWithCurrentItem="True" 
                   IsReadOnly="True"
                   x:Name="dlgMaster" 
                   RowDetailsVisibilityMode="Visible"  
                >
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding Path=MANDANT}"   Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=ROWNID}" Header="{Binding Source={Localization:Translate Word=ID}}"  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=PROG}" Header="{Binding Source={Localization:Translate Word=程序}}"  Width="100" />
                <DataGridTextColumn Binding="{Binding Path=CONTROLS}"  Header="{Binding Source={Localization:Translate Word=属性}}"  Width="80" />
                <!--DataGridTextColumn Binding="{Binding Path=P1}"  Header="{Binding Source={Localization:Translate Word=子控件}}"  Width="80" /-->
                <DataGridTextColumn Binding="{Binding Path=REMARK,Converter={StaticResource gb2312}}" Header="{Binding Source={Localization:Translate Word=说明}}"  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=NEWUSER}" Header="{Binding Source={Localization:Translate Word=创建}}"  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=NEWTIME}" Header="{Binding Source={Localization:Translate Word=日期}}"  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=CHGUSER}" Header="{Binding Source={Localization:Translate Word=修改}}"  Width="Auto" />
                <DataGridTextColumn Binding="{Binding Path=CHGTIME}" Header="{Binding Source={Localization:Translate Word=日期}}"  Width="Auto" />
            </DataGrid.Columns>
        </DataGrid  >
    </Grid>
</me:UIPRG>
